package jnpf.service;

import jnpf.mapper.ClazzMapper;
import jnpf.model.clazz.vo.ClazzVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class ClazzService {

    @Autowired
    private ClazzMapper clazzMapper;

    public List<ClazzVO> listClazz(String sessionId,Integer actived) {
        List<ClazzVO> clazzVO = clazzMapper.listClazz(sessionId,actived);
            clazzVO.stream().map(listVO ->{
                listVO.setChazzShow(listVO.getName() + "班");
                listVO.setClazzShowWithStudentCount(listVO.getChazzShow() + "(" + listVO.getStudentCount() + ")");
                if(listVO.getChargerId() == null) {
                    listVO.setChargerName("未设置");
                }
                return listVO;
            }).collect(Collectors.toList());
            return clazzVO;
        }
    }
